import React, { Component } from 'react';
import { Text, View, Image, TouchableOpacity, Alert, ScrollView, BackHandler, Platform } from "react-native";
import { GLOBAL } from '../../../config/global';
import { style } from '../../../theme/style';
import { AddLongBtn } from './_components/AddLongBtn.js';
import { TitleView } from './_components/TitleView.js';
import { SelectComponent } from './_components/SelectComponent';
import { Common } from '../../../component/common/Common.js';
import { PageStatusIndex } from '../../../component/page-status/PageStatusIndex';
const scale = GLOBAL.SCALE;
import OrderAPIService from './_common/OrderAPIService';
import OrderCreactService from './_common/service';
import { orderBlockStyle, toggleBtnStyle } from './_common/style';
let addBtn = require('../../../imgs/apply/orderAddBtn.png');
import ToastUtil from '../../../utils/toast';
import Dictionary from '../../../utils/dictionary';
import { CURRENCY } from '../../../utils/helper';
import MethodUtil from '../../../utils/MethodUtil';
/*
*orderType  销售->S   采购->P
*periodType 长约->L   普通->S
*tCode   现货->S   长约->L  远期->F   代理->A   E->远期执行  C->背靠背
*/
let pageData;
export class OrderGoodsInfoPage extends Component {
	static navigationOptions = {
		header: ({ navigation }) => {
			let { state: { routes } } = navigation;
			Navigation_routers = routes;//全局的路由
		}
	}
	requesting;
	constructor(props) {
		super(props);
		this.jumpPage = OrderCreactService.jump.bind(this);
		this.resetPage = OrderCreactService.reset.bind(this);
		pageData = {};
		this.state = {
			settlementModal: false,
			settlementValue: '请选择',
			settlementIndex: -1,
			baseDateSettle: '',
			priceType: '',

			goodsData: [],
			planData: [],
			feeData: [],
			status: 'data',
			titleName: '',
			totalFeeAmt: 0,
		}

		this.isfirstToggle = true;
		this.amountData = [];  //总量数据
		this.settlementData = []; //结算基准日期
		this.priceTypeData = [];
		this.tCode = '';
		this.totalAmount = 0;
	}

	initData = () => {
		let { titleName, tCode, orderId, oppoOrderId, longOrderId, orderType, periodType, companyId, deliveryType, companyName, companyIdBuy, companyNameBuy, agencyCompanyId, agencyCompanyName, baseDateSettleName, baseDateSettle, priceType, currency, tradeType, isUnite, orderPlanNotCheckFlag } = this.props.navigation.state.params;
		pageData = { orderId, oppoOrderId, longOrderId, orderType, periodType, companyId, deliveryType, companyName, companyIdBuy, companyNameBuy, agencyCompanyId, agencyCompanyName, currency, tradeType, isUnite, orderPlanNotCheckFlag };
		baseDateSettleName = baseDateSettleName || '请选择';
		baseDateSettle = baseDateSettle || '';
		this.tCode = tCode;
		let settlementIndex = '-1'
		this.settlementData.map((item, index) => {
			if (item.dictKey == baseDateSettle) {
				settlementIndex = index;
			}
		})
		if (tCode === 'L') {
			priceType = priceType || this.priceTypeData[1].dictKey;
		} else if (tCode === 'E') {
			priceType = null;
		} else {
			priceType = priceType || this.priceTypeData[0].dictKey;
		}

		this.setState({
			titleName,
			settlementValue: baseDateSettleName,
			baseDateSettle,
			settlementIndex,
			priceType
		});
	}

	async	componentWillMount () {
		await this.getDicts();
		this.initData();
		await this.getGoodsData();  // 商品数据初始化
		if (this.tCode !== 'QH') {
			this.getPlanData();
			this.getFeeList();
		}
		if (Platform.OS === 'android') {
			BackHandler.addEventListener('hardwareBackPress', this.onBackAndroid);
		}
	}

	componentWillUnmount () {
		if (Platform.OS === 'android') {
			BackHandler.removeEventListener('hardwareBackPress', this.onBackAndroid);
		}
	}

	onBackAndroid = () => {
		if (Navigation_routers[Navigation_routers.length - 1].routeName == 'OrderGoodsInfoPage') {
			Alert.alert(
				'提示',
				'您是要放弃创建当前成交报告吗？',
				[
					{
						text: '放弃', onPress: () => {
							this.props.navigation.goBack()
						}
					},
					{ text: '取消', onPress: () => { } },
				],
				{ cancelable: false }
			)
			return true
		}
	}

	async getDicts () {
		this.settlementData = await Dictionary.get('BASE_DATE_SETTLE');
		this.priceTypeData = await Dictionary.get('EC_PRICE_TYPE');
	}

	togglePrice = (dictKey) => {
		if (this.state.priceType == dictKey) return;

		if (!this.isfirstToggle) {
			this.clearPageData();
			this.setState({ priceType: dictKey });
			return
		}

		Alert.alert('提示', '切换价格会导致当前页面数据清空哦～', [
			{
				text: '取消',
			}, {
				text: '确定切换',
				onPress: () => {
					this.clearPageData();
					this.isfirstToggle = false;
					this.setState({ priceType: dictKey });
				}
			}
		])
	}

	async	clearPageData () {
		let successData = await OrderAPIService.goodsDel({ deleteType: 'ORDER', orderId: pageData.orderId });
		if (successData) {
			this.setState({
				goodsData: [],
				planData: [],
				feeData: [],
				totalFeeAmt: 0,
				settlementModal: false,
				settlementValue: '请选择',
				settlementIndex: -1,
				baseDateSettle: '',
			})

		}
	}

	//选择-结算基准日期
	settlementCallBack = (index) => {
		this.setState({
			settlementModal: false,
			settlementValue: this.settlementData[index].dictName,
			settlementIndex: index,
			baseDateSettle: this.settlementData[index].dictKey
		})
	}

	//获取商品-数据
	async getGoodsData () {
		this.setState({ status: 'loading' });
		let responseData = await OrderAPIService.getGoodsList({ queryType: 'ORDER_ITEM_LIST', orderId: pageData.orderId }) || [];
		//商品总量控制
		let lsamountArr = [];
		responseData.forEach(element => {
			let itemData = {
				goodsName: element.goodsName,  // 商品名字
				itemId: element.itemId,// 商品itemId
				amount: element.quantity,// 总量
				residue: element.quantity // 剩余量
			};
			lsamountArr.push(itemData);
		});
		this.getGoodsTotalAmount(responseData);
		this.amountData = lsamountArr;
		this.setState({
			goodsData: responseData,
			status: 'data'
		})
	}

	//商品-跳转
	goGoodsAdd = (editData) => {
		let { goodsData } = this.state;
		let { orderId, oppoOrderId, longOrderId, orderType, periodType, companyId, deliveryType, companyName, companyIdBuy, companyNameBuy, currency, agencyCompanyName, agencyCompanyId, isUnite, orderPlanNotCheckFlag } = pageData;
		let params = { orderType, periodType, orderId, companyId, companyName, companyIdBuy, companyNameBuy, tCode: this.tCode, priceType: this.state.priceType, currency, isUnite };
		params.goodsStateList = goodsData.map(item => {
			return item.goodsState
		})
		if (editData) {
			params.editData = editData
		}
		if (this.tCode === 'A') {
			params.agencyCompanyName = agencyCompanyName;
			params.agencyCompanyId = agencyCompanyId;
		}
		if (this.tCode === 'E' || this.tCode === 'QH') {
			params.longOrderId = longOrderId;
		};
		if (this.tCode === 'C') {
			params.oppoDeliveryType = deliveryType;
			params.companyIdBuy = companyIdBuy;
			params.companyNameBuy = companyNameBuy;
		} else {
			params.deliveryType = deliveryType;
		}
		params.orderPlanNotCheckFlag = orderPlanNotCheckFlag;
		this.jumpPage('ProductFormPage', params, this.getGoodsData.bind(this));
	}

	//删除商品确认
	removeGoodsConfirm (index) {
		Alert.alert('提示', '确定要删除该商品吗？', [
			{
				text: '取消',
			}, {
				text: '删除',
				onPress: () => {
					this.removeGoodsItem(index);
				}
			}
		])
	}

	getGoodsTotalAmount = (goodsData) => {
		this.totalAmount = 0;
		goodsData.map(item => {
			this.totalAmount = MethodUtil.countObj.add(this.totalAmount, Number.parseFloat(item.amount))
		})
	}

	//删除商品
	async removeGoodsItem (index) {
		let { goodsData, planData } = this.state;
		let removeId = goodsData[index].itemId;
		let subData = {
			deleteType: 'ITEM',
			itemId: removeId
		};
		this.setState({
			status: 'loading'
		})
		let saveData = await OrderAPIService.goodsDel(subData);
		if (!saveData) {
			return
		}
		this.amountData.splice(index, 1);
		goodsData.splice(index, 1);
		this.getGoodsTotalAmount(goodsData);
		let lsPlanData = [];
		planData && planData.forEach((item, index) => {
			let lsPlanList = [];
			item.goodsDeliveryPlanList && item.goodsDeliveryPlanList.map(items => {
				if (items.itemId != removeId) {
					lsPlanList.push(items);
				}
			})
			item.goodsDeliveryPlanList = lsPlanList;
			if (item.goodsDeliveryPlanList.length) {
				lsPlanData.push(item);
			}
		})

		this.setState({
			goodsData,
			planData: lsPlanData,
			status: 'data'
		})
	}

	//交货计划-数据
	async getPlanData () {
		let { goodsData } = this.state;
		if (!goodsData || goodsData.length < 1) {
			return
		}
		this.setState({ status: 'loading' })
		let responsePlanData = await OrderAPIService.getDeliveryPlanList({ queryType: 'DELIVERY_PLAN_LIST', orderId: pageData.orderId }) || [];
		this.setState({
			status: 'data',
			planData: responsePlanData
		})
	}

	//交货计划-跳转
	/* 
			data : 编辑和新增    false -> 新增    数据(商品数据) -> 编辑
			elementAmount: 总量数据
	 */
	goPlanAdd = (data, elementAmount) => {
		if (!this.state.goodsData.length) {
			ToastUtil.showWarning('请先添加商品');
			return;
		}

		let params = {
			orderId: pageData.orderId,
			goodsList: this.state.goodsData,
			type: 'OrderGoodsInfoPage',
			elementAmount: this.amountData,
			tCode: this.tCode,
		}
		if (this.tCode === 'L') {
			params.type2 = 'longDeliveryPlanList'
		}
		if (data) {
			params.editData = data
		}
		this.jumpPage('PlanShopping', params, this.getPlanData.bind(this))
	}

	//交货计划-删除
	async	removePlanItem (index) {
		let { planData } = this.state;
		let subData = {
			submitStep: 'DELETE_DELIVERY_PLAN',
			deliveryPlan: {
				deliveryBeginDate: planData[index].deliveryBeginDate,
				deliveryEndDate: planData[index].deliveryEndDate,
				orderId: planData[index].goodsDeliveryPlanList[0].orderId
			}
		};
		this.setState({ status: 'loading' })
		let saveData = await OrderAPIService.deliveryPlanDel(subData);
		if (!saveData) {
			this.setState({
				status: 'data'
			})
			return
		}
		planData.splice(index, 1);
		this.setState({
			planData,
			status: 'data'
		})
	}

	//预算费用-数据
	async getFeeList () {
		let { goodsData } = this.state;
		if (!goodsData || goodsData.length < 1) {
			return
		}
		this.setState({ status: 'loading' })
		let responseData = await OrderAPIService.getFeeList({ orderId: pageData.orderId }) || [];
		let totalFeeAmt = 0;
		responseData.map(item => {
			totalFeeAmt = MethodUtil.countObj.add(totalFeeAmt, Number.parseFloat(item.feeAmt));
		})
		this.setState({ feeData: responseData, totalFeeAmt, status: 'data' })
	}

	//预算费用-跳转
	goFeeAdd = () => {
		if (!this.state.goodsData.length) {
			ToastUtil.showWarning('请先添加商品');
			return;
		}
		let params = { orderId: pageData.orderId };
		this.jumpPage('FeeAddPage', params, this.getFeeList.bind(this));
	}

	//数据是否填写完整
	checkData = () => {
		let { goodsData, planData, totalFeeAmt } = this.state;
		if (!goodsData.length) {
			ToastUtil.showWarning('请先选择商品');
			return false;
		}
		if (!planData.length) {
			ToastUtil.showWarning('请先选择交货计划');
			return false;
		}
		return true;
	}

	//验证授信额度
	checkCredit = async () => {
		let saveData = await OrderAPIService.orderCreditCheck({ orderId: pageData.orderId }, {
			rejectError: true, //是否将错误数据以reject的方式返回
			handerError: false //统一出错处理 通过toast提示
		});
		if (!saveData) {
			return
		}
		if (!saveData.isReject) {
			return true
		} else {
			//授信额度不通过
			let companyRole = '';
			if (this.tCode === 'C' && (saveData.code == '11' || saveData.code == '13')) {
				//11采购  13销售
				companyRole = saveData.code == '11' ? '供应商' : saveData.code == '13' ? '客户' : '';
				this.showAlert(companyRole);
			} else if (saveData.code == '11' || saveData.code == '13') {
				companyRole = '企业';
				this.showAlert(companyRole);
			} else {
				ToastUtil.showError(saveData.msg || '请求出错啦！')
			}
			return false
		}
	}

	showAlert = (companyRole) => {
		Alert.alert('提示', `${companyRole}循环授信申请金额不足，可前往申请企业授信`, [
			{
				text: '确定',
			}, {
				text: '前往申请',
				onPress: () => {
					this.props.navigation.navigate('CreditFormPage', { companyId: pageData.companyId, orderType: pageData.orderType })
				}
			}
		])
	}

	//下一步/提交/保存
	async	nextStep (str, opType) {
		if (this.requesting) return;
		//下一步&提交审批的时候 验证数据
		if (opType !== 'save' && this.tCode !== 'QH' && !this.checkData()) {
			return
		}

		let { baseDateSettle, priceType, goodsData, planData, totalFeeAmt } = this.state;
		let { orderId, orderType, companyId, orderPlanNotCheckFlag } = pageData;
		let quatityPass = true;
		goodsData.map((goods, gIndex) => {
			goods.planQ = 0;
			planData.map((plan, pIndex) => {
				plan.goodsDeliveryPlanList.map(goodsItem => {
					if (goodsItem.itemId === goods.itemId) {
						goods.planQ += Number.parseFloat(goodsItem.quantity);
					}
				})
			})
			console.log(goods.planQ, goods.quantity, 'goods.planQ > goods.quantity')
			if (goods.planQ > goods.quantity) {
				quatityPass = false;
				ToastUtil.showWarning('商品数量和交货计划数量不一致，请检查交货计划');
				return
			}
		})
		//验证商品和交货计划是否数量正确
		if (this.tCode !== 'QH' && !quatityPass) return;

		let orderInfo = {
			orderId: pageData.orderId,
			oppoOrderId: pageData.oppoOrderId,
		}

		if (this.tCode === 'QH') {
			orderInfo.isQhXhXsBiz = 'Y';
		}

		//暂定价需要更新结算基准日期
		if (priceType == '2') {
			if (!baseDateSettle) {
				ToastUtil.showWarning('请选择结算基准日期');
				return
			}
			orderInfo.baseDateSettle = baseDateSettle
		}

		//验证授信
		if (this.tCode !== 'L' && goodsData.length) {//框架不验证授信
			let creditPass = await this.checkCredit();
			if (!creditPass) return;
		}

		//无结算基准日期下一步
		if (priceType != '2' && !opType) {
			this.props.navigation.navigate('OrderOtherInfoPage', { tCode: this.tCode, orderId, orderType, productList: goodsData, totalFeeAmt, companyId });
			return
		}

		let sendData = {
			submitStep: str,
			orderInfo
		}
		this.setState({
			status: 'loading'
		})
		this.requesting = true;
		let saveData = await OrderAPIService.orderAdd(sendData);
		this.setState({
			status: 'data'
		})


		if (saveData) {
			setTimeout(() => {
				this.requesting = false;
			}, 1000)
			//下一步
			if (!opType) {
				this.props.navigation.navigate('OrderOtherInfoPage', { tCode: this.tCode, orderId, orderType, productList: goodsData, totalFeeAmt, companyId, orderPlanNotCheckFlag });
				return;
			}

			//闭口/代理  提交或保存
			let msg = '已保存到草稿';
			// status 0,1,2,3 已通过 审批中 已驳回 草稿
			//let status = 'RPT_DRAFT';

			let status = 0;
			if (this.tCode == 'E' && submitType == 1) {
				//RPT_AUDITING : 审批 , RPT_AUDIT_PASS : 进行中':
				status = saveData.status == 'RPT_AUDITING' ? '1' : '2';
			} else {
				status = opType == 'submit' ? 1 : 0;
			}

			if (opType == 'submit') {
				msg = '提交成功';
			}
			// if (saveData.status) {
			// 	status = saveData.status
			// }
			ToastUtil.showSuccess(msg).then(() => {
				this.resetPage(orderType, this.tCode, status);
			})

		} else {
			this.requesting = false;
		}
	}

	_headCloes = () => {
		this.props.navigation.goBack()
	}

	render () {
		let { goodsData, planData, feeData, totalFeeAmt, status, titleName, settlementModal, settlementValue, settlementIndex, priceType } = this.state;
		let { tCode } = this;
		let totalAmount = MethodUtil.countObj.add(this.totalAmount, totalFeeAmt);
		let showAddBtn = true; // 默认显示新增商品按钮 
		// 如果已经选择了一种商品并且是液体的，隐藏新增按钮
		if (goodsData && goodsData.length == 1 && (goodsData[0].goodsState == 'FLUID'||goodsData[0].goodsState == 'GAS')) showAddBtn = false
		return (
			<View style={orderBlockStyle.container}>
				<Common type="headCloes" callBack={this._headCloes} />
				<TitleView title={titleName} describe={'执行方式'} />
				<ScrollView showsVerticalScrollIndicator={false}>
					<View style={{ paddingBottom: 100 * scale }}>
						<View style={{ flexDirection: 'row', marginTop: 17 * scale }}>
							<Text style={{ color: "#333", lineHeight: 25 * scale, fontSize: 14 * scale, }}>总价:</Text>
							<Text style={{ color: "#333", lineHeight: 25 * scale, fontSize: 14 * scale, marginLeft: 5 * scale }}>{CURRENCY.format(totalAmount)}{CURRENCY.getUnit(pageData.currency).text}</Text>
						</View>

						{
							tCode != 'E' ? (
								<View style={toggleBtnStyle.listItemActive}>
									<Text style={toggleBtnStyle.keyText} >价格</Text>
									{this.priceTypeData && this.priceTypeData.map((item, index) => {
										if (tCode === 'E' || tCode === 'QH') {
											if (item.dictKey == priceType) {
												return <Text key={index} style={toggleBtnStyle.checkedText}>{item.dictName}</Text>
											}
										} else {
											return <Text key={index} onPress={() => {
												this.togglePrice(item.dictKey);
											}} style={priceType == item.dictKey ? toggleBtnStyle.checkedText : toggleBtnStyle.unCheckText}>{item.dictName}</Text>
										}
									})
									}
								</View>
							) : null
						}

						{priceType && priceType == '2' ? <SelectComponent callBack={() => {
							//长约执行不能修改结算基准日期 结算基准日期为框架的结算基准日期
							if (tCode === 'E') {
								return;
							} this.setState({ settlementModal: true })
						}} name="结算基准日期" type={tCode === 'E' ? 'input' : ''} editable={tCode === 'E' ? false : true} value={settlementValue} /> : null}
						<View>
							{goodsData.length <= 0 ? (
								<TouchableOpacity style={[orderBlockStyle.inputBox, { marginTop: 17 * scale }]} onPress={() => { this.goGoodsAdd(false) }}>
									<Image style={orderBlockStyle.inputKk} source={require('../../../imgs/apply/inputText.png')} />
									<View style={orderBlockStyle.inputNr} >
										<Text>商品信息</Text>
										<Image style={{ width: 6 * scale, height: 11 * scale }} source={require('../../../imgs/arrow-left.png')} />
									</View>
								</TouchableOpacity>
							) : (goodsData.map((item, index) => {
								let { goodsName, quantity, price, deliveryAddressList, endAddressList, customLevelName, goodsState, goodsStateName } = item;
								return (
									<View key={index} style={{ marginTop: 17 * scale }}>
										<TouchableOpacity style={orderBlockStyle.infoBox} key={index} onPress={() => { this.goGoodsAdd(item) }}>
											<Image style={orderBlockStyle.infoImg} source={require('../../../imgs/apply/infoImg.png')} />
											<View style={orderBlockStyle.infoHead}>
												<Text style={orderBlockStyle.infoTitle}>商品信息</Text>
												<Image style={{ width: 6 * scale, height: 11 * scale }} source={require('../../../imgs/arrow-left.png')} />
											</View>
											<View style={orderBlockStyle.infoBody}>
												<Text numberOfLines={2} style={orderBlockStyle.infoText}>
													{goodsName ? (<Text style={orderBlockStyle.infoText}>商品名称:{goodsName}{goodsState == 'FLUID' ? '(' + goodsStateName + ')' : ''}</Text>) : null}
													{quantity ? (<Text style={orderBlockStyle.infoText}>，总量:{quantity}吨</Text>) : null}
													{price ? (<Text style={orderBlockStyle.infoText}>，合同单价:{price}{CURRENCY.getUnit(pageData.currency).text}/吨</Text>) : null}
													{(deliveryAddressList && deliveryAddressList.length > 0) ? (<Text style={orderBlockStyle.infoText}>，出库地:</Text>) : null}
													{deliveryAddressList && deliveryAddressList.map((element, index) => {
														return (element.addressName || element.detailAddress) ? (<Text key={index} style={orderBlockStyle.infoText}>{element.addressName || element.detailAddress} </Text>) : null
													})}
													{(endAddressList && endAddressList.length > 0) ? (<Text style={orderBlockStyle.infoText}>，目的地:</Text>) : null}
													{endAddressList && endAddressList.map((element, index) => {
														return (element.addressName || element.detailAddress) ? (<Text key={index} style={orderBlockStyle.infoText}>{element.addressName || element.detailAddress} </Text>) : null
													})}
												</Text>
												<View style={orderBlockStyle.removeItem}>
													{tCode === 'QH' ? <Text style={{ fontSize: 12 * scale, color: '#3F5877' }}>客户等级：{customLevelName}</Text> : <Text></Text>}
													<Text onPress={() => { this.removeGoodsConfirm(index) }} style={orderBlockStyle.removeBtn}>删除</Text>
												</View>
											</View>
										</TouchableOpacity>
									</View>
								)
							}))
							}
							{(showAddBtn && goodsData.length > 0) ? (<TouchableOpacity style={orderBlockStyle.infoAddBox} onPress={() => { this.goGoodsAdd(false) }}>
								<Image source={addBtn} />
								<Text style={orderBlockStyle.infoAddText}>新增</Text>
							</TouchableOpacity>) : null
							}
						</View>

						{tCode !== 'QH' ? <View style={{ marginTop: 16 * scale }}>
							{planData.length <= 0 ? (
								<TouchableOpacity style={orderBlockStyle.inputBox} onPress={() => { this.goPlanAdd(false, this.amountData) }}>
									<Image style={orderBlockStyle.inputKk} source={require('../../../imgs/apply/inputText.png')} />
									<View style={orderBlockStyle.inputNr} >
										<Text>交货计划</Text>
										<Image style={{ width: 6 * scale, height: 11 * scale }} source={require('../../../imgs/arrow-left.png')} />
									</View>
								</TouchableOpacity>
							) : (planData && planData.map((item, index) => {
								let { deliveryBeginDate, deliveryEndDate, goodsDeliveryPlanList, } = item;
								let goodsArrStr = "";
								goodsDeliveryPlanList && goodsDeliveryPlanList.map((items, indexs) => {
									goodsArrStr += `${items.goodsName || ''}数量:${items.quantity}`;
								})
								return (
									<TouchableOpacity style={orderBlockStyle.infoBox} key={index} onPress={() => { this.goPlanAdd(planData, this.amountData) }}>
										<Image style={orderBlockStyle.infoImg} source={require('../../../imgs/apply/infoImg.png')} />
										<View style={orderBlockStyle.infoHead} >
											<Text style={orderBlockStyle.infoTitle}>交货计划</Text>
											<Image style={{ width: 6 * scale, height: 11 * scale }} source={require('../../../imgs/arrow-left.png')} />
										</View>
										<View style={orderBlockStyle.infoBody}>
											<Text numberOfLines={2} style={orderBlockStyle.infoText}>
												{tCode && tCode !== 'L' ? <Text style={orderBlockStyle.infoText}>开始时间:{deliveryBeginDate}，</Text> : null}
												{tCode && tCode !== 'L' ? <Text style={orderBlockStyle.infoText}>结束时间:{deliveryEndDate}，</Text> : null}
												<Text style={orderBlockStyle.infoText} numberOfLines={1}>{goodsArrStr}</Text>
											</Text>
											<View style={[orderBlockStyle.removeItem, { flexDirection: 'row-reverse' }]}>
												<Text onPress={() => { this.removePlanItem(index) }} style={orderBlockStyle.removeBtn}>删除</Text>
											</View>
										</View>
									</TouchableOpacity>
								)
							})
								)}
						</View> : null}

						{tCode !== 'QH' ? <View style={{ marginTop: 16 * scale }}>
							{totalFeeAmt <= 0 ? (
								<TouchableOpacity style={orderBlockStyle.inputBox} onPress={this.goFeeAdd}>
									<Image style={orderBlockStyle.inputKk} source={require('../../../imgs/apply/inputText.png')} />
									<View style={orderBlockStyle.inputNr} >
										<Text>费用估算</Text>
										<Image style={{ width: 6 * scale, height: 11 * scale }} source={require('../../../imgs/arrow-left.png')} />
									</View>
								</TouchableOpacity>
							) : (
									<TouchableOpacity style={orderBlockStyle.infoBox} onPress={this.goFeeAdd}>
										<Image style={orderBlockStyle.infoImg} source={require('../../../imgs/apply/infoImg.png')} />
										<View style={orderBlockStyle.infoHead}>
											<Text style={orderBlockStyle.infoTitle}>费用估算</Text>
											<Image style={{ width: 6 * scale, height: 11 * scale }} source={require('../../../imgs/arrow-left.png')} />
										</View>
										<View style={orderBlockStyle.infoBody}>
											<Text style={orderBlockStyle.infoText}>总费用:{totalFeeAmt}元</Text>
											{/* {feeData.map((item, index) => {
												return (<Text key={index} style={orderBlockStyle.infoText}>{item.feeTypeName}:{item.feeAmt},</Text>)
											})} */}
										</View>
									</TouchableOpacity>
								)}
						</View> : null}
					</View>
				</ScrollView>
				<Common type="modal" demoData={(
					<Common type="listRadio" selectIndex={settlementIndex} title="结算基准日期" listData={this.settlementData} selectCallBack={this.settlementCallBack} />
				)} isVisible={settlementModal} closeCallballFn={() => { this.setState({ settlementModal: false }) }} />
				<AddLongBtn callBack={() => { this.props.navigation.goBack() }} direction="left" text="上一步" bottom="20" colorBg={style.color.ceruleanUp} />
				{pageData.tradeType === 'O' || tCode === 'C' || tCode === 'QH' || tCode === 'A' || tCode === 'L' ? <TouchableOpacity onPress={() => { this.nextStep('SAVE_ORDER_DRAFT', 'save') }} style={orderBlockStyle.saveBtnBox} >
					<Text style={orderBlockStyle.saveBtn}>保存</Text>
				</TouchableOpacity> : null}
				{pageData.tradeType === 'O' || tCode === 'C' || tCode === 'QH' || tCode === 'A' || tCode === 'L' ? <AddLongBtn callBack={() => { this.nextStep('ORDER_SUBMIT_AUDIT', 'submit') }} text="提交" direction="right" bottom="20" colorBg={style.color.cerulean} /> : <AddLongBtn callBack={() => { this.nextStep('UPDATE_SETTLE_DATE', false) }} direction="right" text="下一步" bottom="20" colorBg={style.color.cerulean} />}
				{
					status != 'data' ? (<View style={orderBlockStyle.statusStyle}><PageStatusIndex status={status} /></View>) : null
				}
			</View >
		)
	}
}
